--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local getShade = function(room, n)
        local ids = {}
        for _, id in ipairs(room.void) do
            if n <= 0 then break end
            if Fk:getCardById(id).name == "shade" then
                room:setCardMark(Fk:getCardById(id), MarkEnum.DestructIntoDiscard, 1)
                table.insert(ids, id)
                n = n - 1
            end
        end
        while n > 0 do
            local card = room:printCard("shade", Card.Spade, 1)
            room:setCardMark(card, MarkEnum.DestructIntoDiscard, 1)
            table.insert(ids, card.id)
            n = n - 1
        end
        return ids
    end
    local idol_bodyguard = fk.CreateCard {
        name = "&idol_bodyguard",
        type = Card.TypeEquip,
        sub_type = Card.SubtypeTreasure,
        equip_skill = "#idol_bodyguard_skill",
    }
    local idol_bodyguard_skill = fk.CreateSkill {
        name = "#idol_bodyguard_skill",
        attached_equip = "idol_bodyguard",
    }
    idol_bodyguard_skill:addEffect(fk.EventPhaseStart, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(idol_bodyguard_skill.name) and target == player and (target.phase == Player.Finish or target.phase == Player.Start)
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            local room = player.room
            if target.phase == Player.Finish then
                local count = player:getMaxCards() - #player:getCardIds("h")
                room:moveCards({
                    ids = getShade(room, count),
                    to = player,
                    toArea = Card.PlayerHand,
                    moveReason = fk.ReasonPrey,
                    proposer = player,
                    skillName = idol_bodyguard_skill.name,
                    moveVisible = true,
                })
            end
            if target.phase == Player.Start then
                local cards = table.filter(player:getCardIds("h"), function(id)
                    return Fk:getCardById(id).name == "shade"
                end)
                room:throwCard(cards, idol_bodyguard_skill.name, player, player)
            end
        end,
    })
    extension:loadSkillSkels { idol_bodyguard_skill }
    extension:loadCardSkels { idol_bodyguard }
    extension:addCardSpec("idol_bodyguard", Card.Spade, 1)
    Fk:loadTranslationTable {
        ["idol_bodyguard"] = "偶像卫队",
        [":idol_bodyguard"] = "装备牌·宝物<br /><b>宝物技能</b>：结束阶段，你用【影】将手牌补至手牌上限；准备阶段，你弃置所有【影】。",
        ["#idol_bodyguard_skill"] = "偶像卫队",
    }
end
